<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {

    public function index(){
//        // 获取当前账户的登录信息
//        $info = M('users')->where(array('uid' => parent::$uid))->find();
//        $this->assign('userinfo', $info);

        $login = 0;

        if (session('uid')) {
            $login = 1;
            $info = M('users')->where(array('uid' => session('uid')))->find();
             $this->assign('userinfo', $info);

            //判断组织者
            if (M("orgnizers")->where(['uid' => session('uid')])->select()){
            $this->assign("org" , 1);}
//        }
//        else
//            $this->ajaxReturn(["code" => 0]);


        }

        $this->assign("login", $login);
        $this->display();
    }




//    public function isOrg()
//    {
//        if (M("orgnizers")->where(['uid' => parent::$uid])->select()){
//            $this->ajaxReturn(["code" => 1]);
//        }
//        else
//            $this->ajaxReturn(["code" => 0]);
//    }
//
//    public function getQuizList()
//    {
//
//
//        $orgnizer_quiz_list = M("orgnizer_userquizlist")
//            ->join("orgnizer_grouptest on orgnizer_grouptest.testgroup_id = orgnizer_userquizlist.testgroup_id")
//            ->where(['uid' => parent::$uid])->select();
//
//
//        //存在于组织者布置的测试当中
//        if ($orgnizer_quiz_list){
//            $quiz_list = json_decode($orgnizer_quiz_list[0]['quiz_list'], true);
//            $oname = M('orgnizers')->where(['oid' => $orgnizer_quiz_list[0]['oid']])->select();
//            $oname = $oname[0]['orgnizer_name'];
//            $rs['orgnizer_name'] = $oname;
//            $rs['orgnizer'] = 1;
//            $rs['detail'] = D("User_answer")->QuizDetail($quiz_list, parent::$uid);
//
//        }
//        //用户单独做的测试
//        else{
//            $rs['orgnizer'] = 0;
//        }
//
//       $this->ajaxReturn($rs);
//
//    }



}